<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>

<script type="text/javascript">
	function categoryInsecptTree_onNodeClick(event, treeId, treeNode) {
		//alert(treeNode.treenodePath);
		//alert(	JSON.stringify(treeNode));
		/**/
		categoryTaskInsecptGrid.search({
			"field" : "categoryId",
			"op" : "eq",
			"data" : treeNode.id
		});

	}

	function getCategoryTreeNode() {
		var node = categoryInsecptTree.zTree.getSelectedNodes();

		if (node && node != "") {
			return "categoryId=" + node[0].id;
		}

		alert("请选择一个节点");
		return false;
	};

	function category_BeforeDeleteFun(treeNode) {

		var result = "";
		$.ajax({
			type : "POST",
			url : "task/inspectCiCateCheck/getPropertyCountByCategoryPath",
			data : "categoryPath=" + treeNode.treenodePath,
			dataType : "json",
			success : function(data) {
				if (data > 0) {

					result = "资产类别或子类别下存在自定义属性，您确定要全部删除？";
				}

			},
			async : false
		});

		return result;
	}
</script>
<table style="table-layout: fixed;width:100%">
	<tr>
		<td style="width:230px;vertical-align: top;border:none;"><isperp:tree
				id="categoryInsecptTree" title="资产分类">
				<isperp:async enable="true" url="configuration/category/getTree">
				</isperp:async>
				<isperp:callback onClick="categoryInsecptTree_onNodeClick">
				</isperp:callback>
			</isperp:tree>
		</td>
		<td style="vertical-align: top">
			<div class="box no-border">
				<div class="header">
					<h2>巡检项</h2>
				</div>
				<isperp:grid url="task/inspectCiCateCheck/listByCiCategory"
					gridId="categoryTaskInsecptGrid" cusFormatterActions="true"
					showPager="false" showSearchbar="false" cusDialogSize="normal"
					cusEditUrl="task/inspectCiCateCheck/edit"
					cusDeleteUrl="task/inspectCiCateCheck/delete"
					ondbClickRowEvent="categoryTaskInsecptGrid.edit(rowid);"
					beforeCreateAction="getCategoryTreeNode();"
					afterActionsSuccess="categoryInsecptTree.reload();">

					<jsp:attribute name="toolbar">
	 				<isperp:toolbar id="categoryTaskInsecptToolbar">
						<isperp:button id="categoryCreate" icon="icon-plus" text="新增巡检项"
								onclick="categoryTaskInsecptGrid.create();"></isperp:button>
	 				</isperp:toolbar>
				 	</jsp:attribute>
					<jsp:body> 
					<isperp:column name="id" title="id" hidden="true"></isperp:column> 
					<isperp:column name="parent_treenode_name_path" title="所属分类"
							width="220">
					</isperp:column>
					<isperp:column name="check_name" title="巡检项" width="100">
					</isperp:column>
					<isperp:column name="check_unit" title="单位" width="80">
					</isperp:column>
					<isperp:column name="data_type" title="类型" width="70"
							isFormatterFun="true"
							formatter="switch(cellvalue){case 'string': return '字符串';case 'number': return '数字';case 'date': return '日期';case 'select':return '下拉选择';}">
					</isperp:column> 
					<isperp:column name="notnull" title="必填项" width="50" align="center"
							formatter="checkbox">
			    	 </isperp:column>
					<isperp:column name="order_num" title="排序" width="50">
					</isperp:column>
				</jsp:body>

				</isperp:grid>
			</div>
		</td>
	</tr>
</table>
